
import pymysql

db = pymysql.connect(
    host='localhost',
    port=3306,
    user='root',
    passwd='1234',
    charset='utf8',
)
# 获取操作游标，即操作数据库的一个对象  
cursor = db.cursor()

cursor.execute("USE crawlerdemo")

cursor.execute('''  
CREATE TABLE IF NOT EXISTS job (  
    `job_id` INT AUTO_INCREMENT PRIMARY KEY,  
    `job_name` VARCHAR(40),  
    `job_sal` INT,  
    `company_name` VARCHAR(30),  
    `job_place` VARCHAR(10),  
    `job_exp` VARCHAR(10),  
    `job_education` VARCHAR(10)  
);  
''')

# 查询所有表名  
cursor.execute('SHOW TABLES')
tables = cursor.fetchall()

print(tables)

cursor.close()
db.close()